<form action="" method="post" class="form-horizontal" novalidate>
	{% csrf_token %}
	<div class="row">
		{% for foo in form %}
			<div class="col-xs-6">
				<div class="form-group col-xs-12">
					<label for="" class="col-sm-2 control-label">{{ foo.item.label }}</label>
					<div class="col-sm-10">
						{{ foo.item }}
						{{ foo.item.errors.0 }}
					</div>
				</div>
				{% if foo.is_popup %}
					<div class="pull-right">
						<a onclick="popup('{{ foo.popup_url }}')"><span class="glyphicon glyphicon-plus"></span></a>
					</div>
				{% endif %}

			</div>

		{% endfor %}
	</div>
	<div class="form-group pull-right">
		<div class="col-sm-offset-2 col-sm-10">
			<button type="submit" class="btn btn-info">提交</button>
		</div>
	</div>
</form>

<script>
    function popup(url) {
        window.open(url, url, 'status=1,width=600,height=500,toolbar=0,resizeable=0')
    }

    function popupClose(data) {
        if (data.status) {
            var oOpt = document.createElement('option');
            oOpt.text = data.text;
            oOpt.value = data.pk;
            oOpt.setAttribute('selected', 'selected');
            document.getElementById(data.popup_id).appendChild(oOpt)
        }
    }
</script>